package com.imooc.miaosha.controller;

import com.imooc.miaosha.domain.MiaoshaUser;
import com.imooc.miaosha.result.Result;
import com.imooc.miaosha.service.MiaoshaUserService;
import com.imooc.miaosha.service.UserService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.CookieValue;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @Author: jackie
 * @Date: 2019/1/5 14:04
 * @Version 1.0
 */
@Controller
@RequestMapping(value = "/goods")
public class GoodsController {

    @Autowired
    MiaoshaUserService userService;

    /*@RequestMapping(value = "/to_list")
    public String list(Model model,
                       @CookieValue(value = MiaoshaUserService.COOKI_NAME_TOKEN) String cookiToken,
                       @RequestParam(value = MiaoshaUserService.COOKI_NAME_TOKEN) String paramToken) {
        if (StringUtils.isEmpty(cookiToken) && StringUtils.isEmpty(paramToken)) {
            return "login";
        }
        String token = StringUtils.isEmpty(paramToken) ? cookiToken : paramToken;
        MiaoshaUser user = userService.getByToken(token);
        model.addAttribute("user", user);
        return "goods_list";
    }*/

    @RequestMapping(value = "/to_list")
    public String list(Model model,MiaoshaUser user) {
        model.addAttribute("user", user);
        return "goods_list";
    }


}
